package com.itheima.socketdemo7;

import java.io.*;
import java.net.Socket;

public class ClientDemo {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1", 10002);

        OutputStream os = socket.getOutputStream();
        String msg = "hello";
        os.write(msg.getBytes("UTF-8"));
        socket.shutdownOutput();

        InputStream is = socket.getInputStream();
        BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"));

        String line;
        while ((line = br.readLine()) != null) {
            System.out.println(line);
        }

        os.close();
        is.close();
        socket.close();

    }
}
